<template>
  <div class="home_m">
    <div class="m_layout" v-infinite-scroll="handleBottomChange" infinite-scroll-distance="10">
      <div class="cart_tip clearfix" v-if="login == false">
        <span>登录后可同步电脑与手机收藏中的商品</span>
        <router-link to="/login" class="login">登录</router-link>
      </div>
      <div class="no-collect" v-if="collectList.length == 0" style="text-align: center">
        <div class="c">
          <img style="width: 50%" src="http://nos.netease.com/mailpub/hxm/yanxuan-wap/p/20150730/style/img/icon-normal/noCart-a8fe3f12e5.png" />
          <br />
          <span style="margin-left: 10px">还没有收藏</span>
        </div>
      </div>
      <div>
        <div>.</div>
        <div>.</div>
        <div>.</div>
        <div class="its" v-for="item in collectList" style="height: 300px;">
          <router-link class="not_eng_link" :to="'/detail/'+item.valueId">
            <img v-lazy="item.picUrl" />
            <div class="not_eng_info">
              <p class="not_eng_title" style="overflow: hidden;text-overflow: ellipsis;
						white-space: nowrap; ">{{item.name}}</p>
              <div class="collect_info clearfix" style="text-align: center">
                <span class="subtitle" style="overflow: hidden;text-overflow: ellipsis;
							white-space: nowrap; ">{{item.brief}}</span>
              </div>
              <p class="not_eng_text">
                <i style="text-decoration: none;font-style: normal;font-size: 12px">¥</i>
                <span class="more_info_price_txt">{{item.retailPrice}}</span>
              </p>
            </div>
          </router-link>
        </div>
      </div>
      <div>.</div>
      <div>.</div>
    </div>
  </div>
</template>
<script>
import { Button, Field, InfiniteScroll, Loadmore } from '../../node_modules/mint-ui'
export default {
  components: {
    Button,
    Field,
    Loadmore,
    InfiniteScroll
  },
  data() {
    return {
      type: 0,
      collectList: [],
      page: 1,
      size: 10,
      totalPages: 1,
      remindValue: ['', '', '赠送'],
      plusFlag: ['', '+', '  '],
      login: ''
    }
  },
  mounted() {
    this.getCollectList()
    this.isLogin()
  },
  methods: {
    getCollectList() {
      let _this = this
      let uObj = {}
      if (window.sessionStorage.userInfo) {
        let uObj = JSON.parse(window.sessionStorage.userInfo)
        console.log(uObj)
        let userId = uObj.id
        _this.$http
          .get('/mechanism/collect/list', {
            params: {
              userId: userId,
              page: _this.page,
              size: _this.size
            }
          })
          .then(res => {
            if (res.data.errno === 0) {
              _this.collectList = res.data.data.collectList
              _this.totalPages = res.data.data.totalPages
              console.log(res.data.collectList + 'list')
            }
          })
      }
    },
    isLogin() {
      if (window.sessionStorage.userInfo) {
        console.log(this.login + 'login')
        this.login = true
        console.log(window.sessionStorage.userInfo)
      } else {
        this.login = false
      }
    },
    handleBottomChange() {
      this.loading = true
      setTimeout(() => {
        if (this.totalPages > this.page) {
          this.page = this.page + 1
          this.getFootprintList()
        }
        this.loading = false
      }, 1500)
    }
  }
}
</script>
